﻿using RndMaterialDisposalService.Attrbutes;
using System.Collections.Concurrent;

namespace RndMaterialDisposalService.LoggingProvider
{
    /// <summary>
    /// 注释掉依赖注入属性，取消自定义日志组件
    /// </summary>
    //[NAutowired(Lifecycle.Singleton)]
    public class LocalFileLoggerProvider : ILoggerProvider
    {
        private readonly ConcurrentDictionary<string, LocalFileLogger> loggers = new();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="categoryName"></param>
        /// <returns></returns>
        public ILogger CreateLogger(string categoryName)
        {
            return loggers.GetOrAdd(categoryName, new LocalFileLogger(categoryName));
        }

        /// <summary>
        /// 
        /// </summary>
        public void Dispose()
        {
            loggers.Clear();
            GC.SuppressFinalize(this);
        }
    }
}
